<?php

#echo "DEBUG: params=<pre>".print_r($params,true)."</pre><br />\n";
#echo "DEBUG: date_fmt=$date_fmt  ,  time_fmt=$time_fmt<br />\n";
#echo "DEBUG: begin: out count=<pre>".sizeof($out)."</pre>\n";
#echo "DEBUG: begin: out=<pre>".print_r($out,true)."</pre>\n";
$out['html'] = "<h3>$out[title]: <strong>$out[name]</strong></h3>
<table style='margin:auto' border=1><tr><th>Time</th><th>$out[header]</th><th>Location</th></tr>\n";
$last_date = $last_time = '';
foreach ($out['rows'] as $row) {
    if ($last_date != $row['start_date']) {
        $out['html'] .= "<tr><td colspan='3' class='ui-widget-header'><strong>$row[start_date]</strong></td></tr>\n";
        $last_date = $row['start_date'];
    }
    if ($row['name']) {
        $loc = ($row['location_name'] ? : '&nbsp;');
        $out['html'] .= "<tr><td>$row[start_time]-$row[end_time]</td><td>$row[name]</td><td>$loc</td></tr>";
    }
}

#echo "DEBUG: out=<pre>".print_r($out,true)."</pre>\n";

print json_encode($out);
